package lq1557_isprime;

import java.util.Scanner;
import java.util.Arrays;
// 1:无需package
// 2: 类名必须Main, 不可修改

public class Main {
	static int[] primes;
	static boolean[] bprime; //注意：下标表示数，取值表示是否质数
	static int count;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		primes = new int[n];
		bprime = new boolean[n];
		isPrime(n);
		for (int i = 0; i < count; i++) {
			System.out.print(primes[i] + " ");
		}
		System.out.println();
		System.out.println(count);
	}

	public static void isPrime(int n) {
		Arrays.fill(bprime, false);
		bprime[0] = true;
		bprime[1] = true;

		for (int i = 2; i < n; i++) {
			if (!bprime[i]) {
				primes[count++] = i;
				for (int j = i * 2; j < n; j += i) {
					bprime[j] = true;
				}
			}
		}
	}
}
